import QtQuick 2.0
import Qt.labs.controls 1.0
import QtQuick.Layouts 1.1
import QtQuick.XmlListModel 2.0
import "../js/TestStartNavigator.qml.js" as Jit
import "../template" as Tm

Tm.Navigator {
    id: nav
    property string uid: ""
    property string name: ""

    Keys.onEscapePressed:  {
        console.log("escaped")
        contentArea.pop()
    }

    Keys.onBackPressed: {
        console.log("backed")
        contentArea.pop()
    }

    ListView{
        id:listView
        anchors.fill: parent
        model: XmlListModel {
            id: xmlModel
            source: http.build("/test.xml?t=s", {uid:usinfo.id})
            query: "/tests/test"

            XmlRole { name: "id"; query: "id/string()" }

            XmlRole { name: "content"; query: "content/string()" }
        }

        delegate: ItemDelegate {
            id: delegate
            width: listView.width

            text: index + 1  + "、"+ content
            onClicked: Jit.open(index, id)
        }
    }

    TestCommitPopupNavigator {
        id: testCommitPop
        onCallback: Jit.add(times, pass, description)
    }
}

